package com.gln.bloger.pojos;

import java.util.Date;
import java.util.Iterator;
import java.util.Set;


/**
 * Role bean.
 * @author renxj
 */
public class Role extends Entity
   implements java.io.Serializable
{
   static final long serialVersionUID = -4254083071697970972L;

   public static final String ROLE_NAME_ADMIN = "admin";
   public static final String ROLE_NAME_AUTHOR = "author";
   public static final String ROLE_NAME_GUEST = "guest";
   private String id;
   private String name;
   private String description;
   private Set<User> users;
   private Date createdTime;

   /**
    * toString
    */
   public String toString()
   {
      StringBuffer str = new StringBuffer("{");

      str.append("id=" + id + " " + "name=" + name + " " 
    		   + "description=" + description + " " 
    		   + "createdTime=" + createdTime+" "
    		   + "users:(");
      Iterator<User> itr = users.iterator();
      while(itr.hasNext()){
    	  User user = itr.next();
    	  str.append(user.getUserName()+",");
      }
      str.append(")");
      str.append('}');

      return(str.toString());
   }

	@Override
	public String getId() {
		return id;
	}
	
	@Override
	public void setId(String id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	public Set<User> getUsers() {
		return users;
	}
	
	public void setUsers(Set<User> users) {
		this.users = users;
	}
	
	public Date getCreatedTime() {
		return createdTime;
	}
	
	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	@Override
	public void setData(Entity other) {
		Role otherRole = (Role)other;
		this.createdTime = otherRole.getCreatedTime();
		this.description = otherRole.getDescription();
		this.id = otherRole.getId();
		this.name = otherRole.getName();
		this.users = otherRole.getUsers();
	}

}
